package principle.interfaceInsulate;

/*
    使用接口隔离原则来实现案例
    将接口拆分为3个小接口，分别有方法1，方法23、方法45
 */
public class Demo02 {
    public static void main(String[] args) {
        A1 a1 = new A1();
        B1 b1 = new B1();
        a1.method1();
        a1.method2();
        a1.method3();
        b1.method1();
        b1.method4();
        b1.method5();
    }
}
interface Interface1{
    public void method1();
}
interface Interface2{
    public void method2();
    public void method3();
}
interface Interface3{
    public void method4();
    public void method5();
}
class A1 implements Interface1,Interface2{
    @Override
    public void method1() {
        System.out.println("A类实现interface1的method1方法");
    }

    @Override
    public void method2() {
        System.out.println("A类实现interface2的method2方法");
    }

    @Override
    public void method3() {
        System.out.println("A类实现interface2的method3方法");
    }
}
class B1 implements Interface1,Interface3{
    @Override
    public void method1() {
        System.out.println("B类实现interface1的method1方法");
    }

    @Override
    public void method4() {
        System.out.println("B类实现interface1的method4方法");
    }

    @Override
    public void method5() {
        System.out.println("B类实现interface1的method5方法");
    }
}

